package com.splant.android.smart.UILevel.Community.fragments;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.splant.android.R;
import com.splant.android.smart.ModelLevel.GatewayListBean;
import com.splant.android.smart.SystemDefinedLevel.LRecyclerview.base.BaseMultiAdapter;
import com.splant.android.smart.SystemDefinedLevel.LRecyclerview.base.SuperViewHolder;
import com.splant.android.smart.UILevel.Community.Garden_WifiConnect_Activity;
import com.splant.android.smart.UILevel.Community.Garden_WifiConnect_Activity;

/**
 * Created by Administrator on 2017/8/17.
 */

public class Garden_GatewayList_Adapter  extends BaseMultiAdapter<GatewayListBean.GateWay> {

    private Context context;
    public Garden_GatewayList_Adapter(Context context) {
        super(context);
        this.context=context;
        addItemType(0, R.layout.garden_gatewaylist_adapter_item);

    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {

        TextView tv_gatewayId=holder.getView(R.id.tv_gatewayId);
        TextView tv_gatewayName=holder.getView(R.id.tv_gatewayName);
        TextView tv_gatewayState=holder.getView(R.id.tv_gatewayState);
        TextView tv_gatewayStartTime=holder.getView(R.id.tv_gatewayStartTime);
        TextView tv_gatewayEndTime=holder.getView(R.id.tv_gatewayEndTime);
        TextView tv_connectWifi=holder.getView(R.id.tv_connectWifi);

        GatewayListBean.GateWay gateWay=getDataList().get(position);

        tv_gatewayId.setText(gateWay.getGatewayId());
        tv_gatewayName.setText(gateWay.getGatewayName());
        if (gateWay.getGatwayState()==1)
            tv_gatewayState.setText("在线");
        else
            tv_gatewayState.setText("离线");

        tv_gatewayStartTime.setText(gateWay.getStOnLine());
        tv_gatewayEndTime.setText(gateWay.getEtOnLine());


        tv_connectWifi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent=new Intent(context, Garden_WifiConnect_Activity.class);

                context.startActivity(intent);

            }
        });


    }

}
